package com.dongdongshop.mq;

import com.dongdongshop.service.ItemPageService;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Service
@RocketMQMessageListener(topic = "staticProducer",consumerGroup = "producer", messageModel = MessageModel.BROADCASTING)
public class MyTestFreemarker implements RocketMQListener<Long> {
    @Autowired
    private ItemPageService itemPageService;

    @Override
    public void onMessage(Long goodsId) {
        try {
            itemPageService.itemDetail(goodsId);
        }catch (Exception e){
            System.out.println("消息消费异常: {}");
            e.printStackTrace();
        }
        System.out.println("消息消费成功: {}");

    }



}
